<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>添加资料</title>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<style type="text/css">
		
	</style>
</head>
<body>
	<%@ include file="include/topbar.jsp" %>
		<div class="container" style="margin-top: 60px">
			<div class="row">
				<jsp:include page="include/left.jsp">
					<jsp:param value="document" name="tag"/>
				
				</jsp:include>
		
		<div class="span9 ">
			 <ul class="breadcrumb" style="margin-bottom:0px;border-radius:3px 3px 0 0">		
				<li >
					<h4>添加新资料</h4>
				</li>
			</ul>
			
			
		<form class="form-horizontal wall" style="">
		<div class="alert "id="alert" style="display:none;width:360px;margin-left:160px">
			<a class="close" href="#">×</a> <strong id="help-msg"></strong>
			</div>
          <div class="control-group">
            <label for="input01" class="control-label">资料标题</label>
            <div class="controls">
              <input type="text" id="goalname" class="input-xlarge" style="width:400px">
              <p class="help-block"></p>
            </div>
         </div>
         
          
         
          <div class="control-group">
            <label for="textarea" class="control-label">资料内容</label>
            <div class="controls">
             <textarea rows="3"  id="desc"class="input-xlarge" style="width:400px;height:300px"></textarea>
            </div>
          </div>
          <div style="padding-left:160px">
            <a class="btn btn-primary" id="btn-primary">确认操作</a>
            <a href="document.jspx" class="btn btn-danger">返回</a>
          </div>
        
      </form>

	</div>
	
	<script type="text/javascript">
		$(document).ready(function() {
			
			$(".close").click(function() {
				$("#alert").hide();
			});
			
			
		
			$("#btn-primary").click(function() {
				var goalname = $("#goalname").val();
				goalname=goalname.replace(/</g,"《");
				goalname=goalname.replace(/>/g,"》");
				var desc = $("#desc").val();
				desc = desc.replace(/</g,"《");
				desc = desc.replace(/>/g,"》");
				if (goalname.trim() == "" || desc.trim() == "") {
					$("#alert").addClass("alert-error").show();
					$("#help-msg").text("资料名称或内容不能为空！");
				} else{
					$.ajax({
						url:"adddocument.jspx",
						type:"POST",
						data:{
							
							title:goalname,
							content:desc
						}
						}
					).done(function(msg){
						if(msg == 1){
							if($("#alert").hasClass("alert-error")){
								$("#alert").removeClass("alert-error");
							}
							$("#alert").addClass("alert-success").show();
							$("#help-msg").text("添加资料成功！");
							$("#goalname").val("");
							$("#desc").val("");
						}else{
							$("#alert").addClass("alert-error").show();
							$("#help-msg").text("添加失败！");
							
						}
					});
				}
			});
		});
		</script>
</body>
</html>
